package vsy.buzzwordbingo.util;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.PageContext;

import org.apache.tiles.context.TilesRequestContext;

public class ViewPreparerUtil {

	public static HttpServletRequest getHttpServletRequest(TilesRequestContext tilesContext) {
		Object[] requestObjects = tilesContext.getRequestObjects();
		if (requestObjects != null) {
			for (Object requestObject : requestObjects) {
				if (requestObject instanceof PageContext) {
					ServletRequest request = ((PageContext)requestObject).getRequest();
					if (request instanceof HttpServletRequest) {
						return (HttpServletRequest)request;
					}
				}
			}
		}
		return null;
	}
}
